<template>
	<view>
		<view class="top-detail">
			<view class="logo">
				<image :src="company?.logo" mode="aspectFill" ></image>
			</view>
			<view class="campany-name-detail">
				<text>{{company?.name}}</text>
			</view>
			<view class="campany-tpye-detail">
				<text>{{company?.industry[0]}}</text>
			</view>
			<view class="campany-location-detail">
				<image src="../../static/images/icon_location.png" mode=""></image>
				<text>{{company?.location.adress}}</text>
			</view>
		</view>
		<custom-tab v-model="actIdx"></custom-tab>
		<view v-if="actIdx==0">
			<view class="padding bg-white" >
				<view class="text-bold">
					公司简介
				</view>
				<view class="text-grey">
					{{company?.description}}
				</view>
			</view>
			<view class="padding bg-white margin-top-sm">
				<view class="text-bold">
				    公司地址
				</view>
				<view class="text-grey">
					{{company?.location.main}}
				</view>
			</view>
			<view class="padding bg-white">
				<view class="text-bold">
					法人代表
				</view>
				<view class="text-grey">
					{{company?.legalInfo.representative}}
				</view>
			</view>
			<view class="padding bg-white">
				<view class="text-bold">
					员工人数
				</view>
				<view class="text-grey">
					22222
			    </view>
			</view>
			<view class="padding bg-white">
				<view class="text-bold">
					注册资本
				</view>
				<view class="text-grey">
					{{company?.legalInfo.registrationNumber}}
				</view>
			</view>
		</view>
		<view class="padding">
			<company-job></company-job>
		</view>
		<view class="cu-bar foot">
			<button class="cu-btn bg-orange" @click="handleJob">
				岗位关联
			</button>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { onLoad } from '@dcloudio/uni-app'
	import http from '../../utils/request'
    import {type Ref, ref } from 'vue'
	import type { CompanyType , JobType} from '../../model/company'
import jobData from '../../utils/job'
	const company:Ref<CompanyType|null>=ref(null)
	onLoad(async(options)=>{
		let companyId=options?.id||'689465652b44ae16344e966b'
		// let res=await http.get('/classes/company',{
		// 	params:{
		// 		where:{
		// 			"objectId":companyId
		// 		}
		// 	}
		// }).then(()=>{
		// 	console.log('单个公司',res);
		// })
		let res =await http.get(`/classes/company/${companyId}`)
		console.log('详情数据',res);
		company.value=res.data
	})
	// 菜单交互
	const actIdx = ref<number>(0)
	const jobList:Ref<Array<JobType>>=ref([])
	jobData.forEach(item=>{
		
	})
	// //批量关联
	// const handleJob =()=>{
	// 	let checkList =jobList.value.filter(item=>item.check)
	// 	let arr=checkList.map(item=>{	
	// 		return{
	// 			method:"post",
	// 			path:"/1.1/class/job",
	// 			body:{
	// 				...item,
	// 				companyId:company.value.objectId,
	// 				logo:company.value.logo,
	// 				company_name:company.value.company_name
	// 			}
	// 		}
	// 	})
	// 	http.post('/batch',{requests:arr})
	// }
</script>

<style lang="scss">
	.logo{
		width: 146.79rpx;
		height: 146.79rpx;
	}
	.logo image{
		border-radius: 25rpx;
		width: 146.79rpx;
		height: 146.79rpx;
	}
	.campany-name-detail{
		font-size: 50.46rpx;
		font-weight:bolder;
		margin-top: 30rpx;
	}
	.campany-tpye-detail{
		font-size: 32.11rpx;
		color: rgba(102, 110, 122, 1);
		margin-top: 20rpx;
	}
    .campany-location-detail{
		display: flex;
		align-items: center;
	}
	.campany-location-detail image{
		width: 82.57rpx;
		height:82.57rpx ;
		
	}
	.campany-location-detail text{
		font-size:36.7rpx ;
		margin-left: 30rpx;
	}
	page{
		background-color: #fff;
	}
	.top-detail{
		display: flex;
		flex-direction: column;
		align-items: center; /* 子元素水平居中 */
		text-align: center; /* 文本居中 */
		padding: 50rpx;
	}
	.text-grey{
		line-height: 60upx;
		margin-top: 10upx;
	}
	.job-active{
		border-color: #FD7753 !important;
		border-width: 1px !important;
	}
	.cu-bar .foot button{
		width: 90%;
		margin-left: -5%;
	}
</style>